package com.itheima.arrlist;

import java.util.ArrayList;

public class ArrayListDemo01 {
    public static void main(String[] args) {
        //创建集合容器对象
        ArrayList<String> list = new ArrayList<>();
        list.add("111");
        list.add("222");
        list.add("333");
        list.add("444");
        list.add("666");
        boolean b = list.remove("111"); //把,111 元素删除
        System.out.println(b);  //true
        System.out.println(list);  //结果! [222, 333, 444, 666]
        String remove = list.remove(2); //删除第三个索引.
        System.out.println(remove); //444
        System.out.println(list); //[222, 333, 666]
        String set = list.set(2, "555"); //设置2索引555
        System.out.println(list.get(2));  // 返回修改的元素 555
        System.out.println(list); //结果:[222, 333, 555]
        System.out.println(list.size());//集合中元素的个数 3

    }
}
